package com.longcai.controller.homepage;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.longcai.bean.ApiResult;
import com.longcai.entity.homepage.ClyjMenu;
import com.longcai.service.homepage.ClyjMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author LWK
 * @since 2019-03-20
 */
@Controller
@RequestMapping("/clyjMenu")
public class ClyjMenuController {
    @Autowired
    ClyjMenuService clyjMenuService;

    /**
     * description: 首页菜单展示
     * author: LWK
     * time： 09点58分
     */
    @RequestMapping("/getMenuList")
    @ResponseBody
    public ApiResult<List<ClyjMenu>> getHomepageBannerList() {
        ApiResult<List<ClyjMenu>> result = new ApiResult<List<ClyjMenu>>();
        try {
            QueryWrapper<ClyjMenu> queryWrapper = new QueryWrapper<ClyjMenu>();
            queryWrapper.eq("del_flag", "0");
            queryWrapper.eq("menu_type", "1");
            queryWrapper.orderByAsc("menu_sort");
            result.success();
            result.setData(clyjMenuService.selectList(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            result.setCode("-1");
            result.fail("查询失败：" + e.getMessage());
        }
        return result;
    }


}

